//
//  UIFont+ItalicFont.m
//  CoolRollerSkating
//
//  Created by 谢伟康 on 15/11/12.
//  Copyright © 2015年 Coollang. All rights reserved.
//

#import "UIFont+ItalicFont.h"
#import "GlobalSetting.h"

@implementation UIFont (ItalicFont)

+(UIFont *)italicFontWithFontName:(NSString *)fontName fontSize:(CGFloat)fontSize italicDegree:(CGFloat)italicDegree
{
    CGAffineTransform matrix =  CGAffineTransformMake(1, 0, tanf(italicDegree * (CGFloat)M_PI / 180), 1, 0, 0);
    
    UIFontDescriptor *desc = [ UIFontDescriptor fontDescriptorWithName :fontName matrix :matrix];
    
    return [UIFont fontWithDescriptor :desc size :fontSize];

}

+(UIFont *)italicFontWithItalicDegree:(CGFloat)italicDegree font:(UIFont *)font
{
    CGAffineTransform matrix =  CGAffineTransformMake(1, 0, tanf(italicDegree * (CGFloat)M_PI / 180), 1, 0, 0);
    
    UIFontDescriptor *desc = [ UIFontDescriptor fontDescriptorWithName :font.fontName matrix :matrix];
    
    return [UIFont fontWithDescriptor :desc size :font.pointSize];
}

+ (UIFont *)systemFontOfSize_6:(CGFloat)size
{
    UIFont *font = nil;
    
    CGFloat scale = kSCREEN_WIDTH_RATIO;
    if (scale > 1.1 && scale < 1.2)
    {
        scale = 1.05;
    }
    else if (scale > 1.2)
    {
        scale = 1.1;
    }
    
    font = [UIFont systemFontOfSize:size*scale];
    
    return font;
}

@end
